package org.blog.model;

import org.blog.util.StringHelper;

public class ModelBanIP extends BaseModel implements ValidateModel {

	private String ip;// 16 ip地址
	private Integer banType = 1;// 0查看页面，1注册
	private Long createTime;// 13 创建时间
	private Integer check = 1;// 是否有效 0无效（不起作用），1有效（起作用）
	private String mark;// 13 说明

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public Integer getBanType() {
		return banType;
	}

	public void setBanType(Integer banType) {
		this.banType = banType;
	}

	public Long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Long createTime) {
		this.createTime = createTime;
	}

	public Integer getCheck() {
		return check;
	}

	public void setCheck(Integer check) {
		this.check = check;
	}

	public String getMark() {
		return mark;
	}

	public void setMark(String mark) {
		this.mark = mark;
	}

	@Override
	public boolean validate(ActionType type) {

		if (ActionType.ADD.equals(type)) {
			if (StringHelper.isEmptyTrim(getIp()) || getBanType() == null
					|| getCheck() == null) {
				return false;
			}
		} else if (ActionType.MODIFY.equals(type)) {
			if (StringHelper.isEmptyTrim(getIp()) || getBanType() == null
					|| getCheck() == null) {
				return false;
			}
		} else if (ActionType.GET.equals(type)) {
			if (getId() == null) {
				return false;
			}
		} else if (ActionType.SELECT.equals(type)) {
			if (getBanType() == null || getCheck() == null) {
				return false;
			}
		}
		return true;
	}

}
